package javax.util;

import java.util.ArrayList;
import java.util.Collection;

import com.kinyx.framework.annotation.assist.CanNotNull;
import com.kinyx.framework.annotation.assist.CanNull;
import com.kinyx.framework.annotation.assist.Note;
import com.kinyx.framework.annotation.assist.ReturnNotNull;

/**
 * 扩展实现ArrayList
 * @param <E> 元素泛型
 * @see java.util.ArrayList
 */
@SuppressWarnings("serial")
public final class XArrayList<E> extends ArrayList<E> {

	public XArrayList() { super(); }

	public XArrayList(final Collection<? extends E> c) { super(c); }

	public XArrayList(final int initialCapacity) { super(initialCapacity); }

	/**
	 * 增加元素
	 * @param e 元素
	 * @return 本对象
	 */
	@ReturnNotNull
	@Note("return this;")
	public XArrayList<E> xAdd(@CanNull final E e) {
		this.add(e);
		return this;
	}

	/**
	 * 增加元素
	 * @param c 元素集合
	 * @return 本对象
	 */
	@ReturnNotNull
	@Note("return this;")
	public XArrayList<E> xAddAll(@CanNotNull final Collection<? extends E> c) {
		this.addAll(c);
		return this;
	}

}
